<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise API - race</title>
</head>
<body>
    <script>
        /***
         *  Promise.race 方法: (promises) => {}
            (1) promises: 包含 n 个 promise 的数组
            说明:返回一个新的 promise,第一个完成的promise的结果状态就是最终的结果状态(就像是在赛跑)
         * 
         *   race:单词意思是赛跑的意思
         ***/

         let p1=new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve('Ok');
                },1000);
         });

         let p2=Promise.resolve('Success');

         let p3=Promise.resolve('Oh Year');

         const result=Promise.race([p1,p2,p3]);
        
         console.log(result);

    </script>
</body>
</html>